package haw.its.a2;

public class LCG {

	private final long a, b, n;
	private long seed;

	public LCG(long a, long b, long n, long seed) {
		super();
		this.a = a;
		this.b = b;
		this.n = n;
		this.seed = seed;
	}

	public double nextValue() {
		seed = (a * seed + b) % n;

		return Double.longBitsToDouble(seed) / Double.longBitsToDouble(n);
	}

	public static void main(String[] args) {
		LCG lcg = new LCG(214013, 13523655, 2 ^ 24, 3);
		int i = 0;
		while (i <= 10) {
			System.out.println(lcg.nextValue());
			i++;
		}
	}

}
